import 'package:flutter/material.dart';

// 顶部的收付款、钱包组件
class ServiceTopWidget extends StatelessWidget {
  const ServiceTopWidget({super.key});

  @override
  Widget build(BuildContext context) {

    // 每个组件样式
    Widget itemWidget({
      required String title,
      required String imgUrl,
      num? money,
      VoidCallback? onTap,
    }) {
      return Expanded(
          flex: 1,
          child: InkWell(
            onTap: onTap,
            child: Padding(
              padding: const EdgeInsets.only(top: 30),
              child: Column(
                  children: [
                    // Icon(iconName, color: Colors.white, size: 32,),
                    Image.asset(imgUrl, width: 32),
                    const SizedBox(height: 8,),
                    Text(title, style: const TextStyle(color: Colors.white, fontSize: 16),),
                    const SizedBox(height: 2,),
                    if (money != null) Text(
                      '¥ $money',
                      style: const TextStyle(color: Colors.white60, fontSize: 12),
                    ),
                  ]
              ),
            ),
          )
      );
    }

    return Container(
      height: 140,
      decoration: const BoxDecoration(
        color: Colors.green,
        borderRadius: BorderRadius.all(Radius.circular(8)),
      ),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          itemWidget(
              title: '收付款',
              imgUrl: 'assets/images/service/收付款.png',
              onTap: () {
                debugPrint('收付款');
              }
          ),
          itemWidget(
              title: '钱包',
              imgUrl: 'assets/images/service/钱包.png',
              money: 3.79,
              onTap: () {
                Navigator.pushNamed(context, 'WalletPage');
              }
          ),
        ],
      ),
    );
  }
}